stat = CredentialsWrong;
} else if (reply->error() != QNetworkReply::NoError) {
- _errors << job->errorStringParsingBody();
+ QByteArray body;
+ _errors << job->errorStringParsingBody(&body);
const int httpStatus =
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (httpStatus == 503) {
_errors.clear();
stat = ServiceUnavailable;
+ } else if (httpStatus == 403) {
+ const auto davException = job->errorStringParsingBodyException(body);
+ if (davException == QStringLiteral(R"(OCA\TermsOfService\TermsNotSignedException)")) {
+ qCInfo(lcConnectionValidator) << "The terms of service need to be signed";
+ stat = NeedToSignTermsOfService;
+ }
}
}
#include "networkjobs.h"
#include "owncloudgui.h"
#include "owncloudsetupwizard.h"
+#include "owncloudpropagator_p.h"
#include "sslerrordialog.h"
#include "wizard/owncloudwizard.h"
#include "wizard/owncloudwizardcommon.h"
// Provide messages for other errors, such as invalid credentials.
} else if (reply->error() != QNetworkReply::NoError) {
+ auto davException = OCC::getExceptionFromReply(reply);
+
if (!_ocWizard->account()->credentials()->stillValid(reply)) {
errorMsg = tr("Access forbidden by server. To verify that you have proper access, "
"<a href=\"%1\">click here</a> to access the service with your browser.")
.arg(Utility::escape(_ocWizard->account()->url().toString()));
+ } else if (!davException.first.isEmpty() && davException.first == QStringLiteral(R"(OCA\TermsOfService\TermsNotSignedException)")) {
+ qCInfo(lcWizard) << "Terms of service not accepted yet!";
+ // TODO: it would be cool to display a new wizard page containing the terms of service
+ errorMsg = tr("Please accept the <a href=\"%1\">Terms of Service</a> with your browser and try again.")
+ .arg(Utility::escape(_ocWizard->account()->url().toString()));
} else {
errorMsg = job->errorStringParsingBody();
}
return {};
}
const auto httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- // only for BadRequest and UnsupportedMediaType
- if (httpStatusCode != 400 && httpStatusCode != 415) {
+ // only for BadRequest, Forbidden, and UnsupportedMediaType
+ if (!(httpStatusCode == 400 || httpStatusCode == 403 || httpStatusCode == 415)) {
return {};
}